package com.dujiu.leetcode.slidingWindow.fixed_lengthSlidingWindow;

import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class P1461 {
    public boolean hasAllCodes(String s, int k) {
        StringBuilder str = new StringBuilder();
        char[] chars = s.toCharArray();
        Set<String> set = new HashSet<>();
        int n = chars.length;
        for (int i = 0; i < n; i++) {
            str.append(chars[i]);
            if (i < k-1){
                continue;
            }
            set.add(str.toString());
            // 将最前面的字符删除
            str.deleteCharAt(0);
        }
        return set.size() == Math.pow(2,k);
    }
}
